function [onsets offsets] = expan_segmenta_rms_mean(rms, meanrms)

rms_mean_scale = 0.2;

len = length(rms);

onsets = [];
offsets = [];

regions = (rms < (meanrms * rms_mean_scale)); 

i=find(~regions, 1);
while (i < len)
   %localizar offset
   i = i-1 + find(regions(i:end), 1);
   offsets = [offsets i];

   % nao buscar onsets no final do sinal
   if (isempty(i)) 
       break;
   end

   %localizar onset
   i = i-1 + find(~regions(i:end), 1);
   onsets = [onsets i];

   % nao buscar offsets se o vetor acabou
   if (isempty(i)) 
       offsets = [offsets length(rms)];
       break;
   end
end
